module ModelSchemaInfo
  class Results < Array

    def add(klass, assosiations, columns)
      result = find_result(klass) || Result.new(klass.to_s)
      result.assosiations = assosiations
      result.columns      = columns
      self << result
    end

    private

      def find_result(klass)
        self.find { |result| result.model_name == klass.to_s }
      end

      ## attributes
      # model_name   = ModelName succeed ActiveRecode::Base class to string
      # assosiations = active_record_model.reflect_on_all_associations
      # columns      = active_record_model.content_columns
      class Result
        attr_accessor :model_name, :assosiations, :columns

        def initialize(model_name)
          @model_name   = model_name
          @assosiations = []
          @columns      = []
        end

      end
  end
end
